package com.jinbo.footmessage.baiduMap;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;


import com.jinbo.footmessage.R;

import java.util.ArrayList;

public class SelectAddressLocAdapter extends BaseAdapter {
		private Context context; //�����Ķ�������
		private int cur_pos=-1; //�б�λ��
		ArrayList<String> address_name;
		ArrayList<String> address_detail;
		public SelectAddressLocAdapter(Context context, ArrayList<String> address_name, ArrayList<String> address_detail)//,int currentPos)
		{
			this.context = context;
			this.address_name=address_name;
			this.address_detail=address_detail;
		}
		
		public SelectAddressLocAdapter(Context context, ArrayList<String> address_name, ArrayList<String> address_detail, int currentPos)
		{
			this.context = context;
			this.cur_pos = currentPos;
			this.address_name=address_name;
			this.address_detail=address_detail;
		}
		public void setCurrentPos(int currentPos)
		{
			this.cur_pos= currentPos;
			notifyDataSetChanged(); //֪ͨѡ���б�ı�
		}
		
		@Override
		public int getCount()
		{
			return address_name.size();
		}

		@Override
		public Object getItem(int position) {
			// TODO Auto-generated method stub
			return position;
		}
		
		@Override
		public long getItemId(int position) {
			// TODO Auto-generated method stub
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			// TODO Auto-generated method stub
			convertView= LayoutInflater.from(context).inflate(R.layout.list_selectaddress_item,null);
			TextView name=(TextView)convertView.findViewById(R.id.address_name);
			TextView detail=(TextView)convertView.findViewById(R.id.address_detail);
			ImageView iv=(ImageView)convertView.findViewById(R.id.get);
			name.setText(address_name.get(position));
			detail.setText(address_detail.get(position));
			if (cur_pos!=-1&&position == cur_pos) { 
				iv.setVisibility(View.VISIBLE);
				} 
			return convertView;
		}
}
